package game.helper;

import java.util.Random;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import game.ability.AbilityManager;
import game.ability.MovingLeft;
import game.ability.Shot;
import game.entity.BufferSpriteManager;
import game.entity.Monster;
import game.entity.SpriteManager;
import game.shared.Constants;

public class Level {
	public static int level;
	
	public Level(){
//		Level.level = Constants.LEVEL_DEFAULT;
	}
	public Level(int level){
//		Level.level = level;
	}
	public void addResource(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		switch (Level.level) {
		case 1:
			addMonster_1(sb, abilityManager, armyManager, monsterManager, weaponManager, random);
			break;
		case 2:
			addMonster_2(sb, abilityManager, armyManager, monsterManager, weaponManager, random);
			break;
		case 3:
			addMonster_3(sb, abilityManager, armyManager, monsterManager, weaponManager, random);
			break;
		case 4:
			addMonster_4(sb, abilityManager, armyManager, monsterManager, weaponManager, random);
			break;
		case 5:
			addMonster_5(sb, abilityManager, armyManager, monsterManager, weaponManager, random);
			break;
//		case 6:
//			addMonster_6(sb, abilityManager, armyManager, monsterManager, weaponManager, random);
//			break;
		}
	}
	private void addMonster_1(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		Monster monster_1 = new Monster(BufferSpriteManager.getSpriteBufferByID(BufferSpriteManager.BUFFER_SPRITE_MONSTER_1));
		monster_1.setMoving(new MovingLeft(Constants.SPEED_MONSTER));
		monster_1.setPosition(Constants.SCREEN_WIDTH + random.nextInt(50), 15 + random.nextInt(80));
		Shot shot = new Shot(abilityManager, sb, monster_1, Constants.ROCKET_AMMUNITION, 2, weaponManager, 2f, armyManager.getByIndex(0));
		monster_1.addAbility(shot);
		monsterManager.add(monster_1);
	}
	private void addMonster_2(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		Monster monster_2 = new Monster(BufferSpriteManager.getSpriteBufferByID(BufferSpriteManager.BUFFER_SPRITE_MONSTER_2));
		monster_2.setMoving(new MovingLeft(Constants.SPEED_MONSTER));
		monster_2.setPosition(Constants.SCREEN_WIDTH + random.nextInt(50), 15 + random.nextInt(80));
		Shot shot = new Shot(abilityManager, sb, monster_2, Constants.ROCKET_AMMUNITION, 2, weaponManager, 2f, armyManager.getByIndex(0));
		monster_2.addAbility(shot);
		monsterManager.add(monster_2);
	}
	private void addMonster_3(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		Monster monster_3 = new Monster(BufferSpriteManager.getSpriteBufferByID(BufferSpriteManager.BUFFER_SPRITE_MONSTER_3));
		monster_3.setMoving(new MovingLeft(Constants.SPEED_MONSTER));
		monster_3.setPosition(Constants.SCREEN_WIDTH + random.nextInt(50), 15 + random.nextInt(80));
		Shot shot = new Shot(abilityManager, sb, monster_3, Constants.ROCKET_AMMUNITION, 2, weaponManager, 2f, armyManager.getByIndex(0));
		monster_3.addAbility(shot);
		monsterManager.add(monster_3);
	}
	private void addMonster_4(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		Monster monster_4 = new Monster(BufferSpriteManager.getSpriteBufferByID(BufferSpriteManager.BUFFER_SPRITE_MONSTER_4));
		monster_4.setMoving(new MovingLeft(Constants.SPEED_MONSTER));
		monster_4.setPosition(Constants.SCREEN_WIDTH + random.nextInt(50), 15 + random.nextInt(80));
		Shot shot = new Shot(abilityManager, sb, monster_4, Constants.ROCKET_AMMUNITION, 2, weaponManager, 2f, armyManager.getByIndex(0));
		monster_4.addAbility(shot);
		monsterManager.add(monster_4);
	}
	private void addMonster_5(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		Monster monster_5 = new Monster(BufferSpriteManager.getSpriteBufferByID(BufferSpriteManager.BUFFER_SPRITE_MONSTER_5));
		monster_5.setMoving(new MovingLeft(Constants.SPEED_MONSTER));
		monster_5.setPosition(Constants.SCREEN_WIDTH + random.nextInt(50), 15 + random.nextInt(80));
		Shot shot = new Shot(abilityManager, sb, monster_5, Constants.ROCKET_AMMUNITION, 2, weaponManager, 2f, armyManager.getByIndex(0));
		monster_5.addAbility(shot);
		monsterManager.add(monster_5);
	}
	private void addMonster_6(SpriteBatch sb, AbilityManager abilityManager, SpriteManager armyManager, SpriteManager monsterManager, SpriteManager weaponManager, Random random){
		Monster monster_6 = new Monster(BufferSpriteManager.getSpriteBufferByID(BufferSpriteManager.BUFFER_SPRITE_MONSTER_6));
		monster_6.setMoving(new MovingLeft(Constants.SPEED_MONSTER));
		monster_6.setPosition(Constants.SCREEN_WIDTH + random.nextInt(50), 15 + random.nextInt(80));
		Shot shot = new Shot(abilityManager, sb, monster_6, Constants.ROCKET_AMMUNITION, 2, weaponManager, 2f, armyManager.getByIndex(0));
		monster_6.addAbility(shot);
		monsterManager.add(monster_6);
	}

//	public void update(){
//		calLevel();
//	}
//	private void calLevel(){
//		if(Constants.MONSTER_NUMBER > Constants.MONSTER_NUMBER_MAX){
//			Constants.MONSTER_NUMBER = 0;
//			Level.level++;
//			Constants.MONSTER_NUMBER_MAX += 2;
//		}
//	}
//	public boolean levelUp(){
//		if(Constants.LEVEL > this.level){
//			this.level = Constants.LEVEL;
//			return true;
//		}
//		return false;
//	}
}
